#include<graphics.h>

class Button{
	public:
	    PIMAGE img;
		int x,y;
		int width,height;
	
	public:
	    Button(const char* i,int x1,int y1,int w,int h){
	    	img=newimage();
	    	getimage(img,i);
	    	x=x1;
	    	y=y1;
	    	width=w;
	    	height=h;
		}
		
		~Button(){
			delimage(img);
		} 
		
		//将按钮打印在画布上 
		void draw(){
			putimage(x,y,width,height,img,0,0,getwidth(img),getheight(img));
		}
		
		//判断按钮是否被按下
		bool is_click(int x1,int y1){
			if(x1>=x&&x1<=x+width&&y1>=y&&y1<=y+height){
				return true;
			}else{
				return false;
			}
		} 
};

//画出UI画布的函数
void init_UI(){
	//先画出右边的白矩形 
	setfillcolor(BLUE);
	bar(16*32,0,20*32,16*32);
	
	//再画出“贪吃蛇”三个字
	setfont(20,0,"宋体");
	setfontbkcolor(WHITE);
	setcolor(BLACK);
	
	outtextxy(17*32,1*32,"贪吃蛇");
	
	PIMAGE img=newimage();
	getimage(img,"./图片资源/MuRaSaMe.png");
	putimage(16*32,11*32,4*32,4*32,img,0,0,getwidth(img),getheight(img));
	delimage(img);
	
	return; 
} 